import React, { PropsWithChildren } from "react";
import {ProBox, ProAutoScrollbars} from "@yaf/pro-ui";


export interface NAutoHeightProps{
  className?: string,
  style?: React.CSSProperties,
  contentClassName?: string,
  contentStyle?: React.CSSProperties,
  headerRender?: React.ReactNode,
  footerRender?: React.ReactNode,
  loading?: boolean,
  isNoData?: boolean,
}

export const NAutoHeight: React.FC<PropsWithChildren<NAutoHeightProps>> = ({className = '', style, contentClassName = "", contentStyle, headerRender, footerRender, loading=false, isNoData = false, children}) => {

  return <div className={`flex flex-col ${className}`} style={style}>
    {headerRender}

    <div className={`grow h-0  ${contentClassName}`} style={contentStyle}>
      <ProAutoScrollbars>
        <ProBox loading={loading} isNoData={isNoData}>
          {children}
        </ProBox>
      </ProAutoScrollbars>
    </div>

    {footerRender}
  </div>
}

